package com.gnerv.battle.boot.module.base.autoconfigure;

import com.gnerv.battle.boot.plugin.openapi.autoconfigure.BattlePluginOpenapiAutoConfiguration;
import io.swagger.v3.oas.models.OpenAPI;
import lombok.extern.slf4j.Slf4j;
import org.springdoc.core.models.GroupedOpenApi;
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author Gnerv LiGen
 */
@Slf4j
@Configuration
@ConditionalOnWebApplication
@ConditionalOnClass({OpenAPI.class, GroupedOpenApi.class})
@AutoConfigureBefore(value = {BattlePluginOpenapiAutoConfiguration.class})
@EnableConfigurationProperties
public class BattleBaseOpenApiAutoConfiguration {

    @Bean
    public GroupedOpenApi manageApi() {
        return GroupedOpenApi.builder()
                .group("manage")
                .pathsToMatch("/api/manage/**")
                .build();
    }

}
